
src_dir="src"
rm -rf $src_dir

source /etc/profile

if [ ! -d "$src_dir" ]; then
	git clone https://git.oschina.net/wr4ng1er/tengine.git src	
else
	echo $src_dir
fi 

cd $src_dir

sed -i "s/opt\/local/opt\/google-perftools/g"  auto/lib/google-perftools/conf

patch -p1 < ../module/nginx_tcp_proxy_module/tcp.patch   


./configure \
--with-ld-opt="-Wl,-rpath,$LUAJIT_LIB" \
--prefix=/opt/tengine \
--dso-path=/opt/tengine/dso \
--pid-path=/opt/tengine/run/nginx.pid \
--lock-path=/opt/tengine/run/nginx.lock \
--user=www \
--group=www \
--with-rtsig_module \
--with-file-aio \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_random_index_module \
--with-mail \
--with-mail_ssl_module \
--with-http_spdy_module \
--with-pcre-jit \
--with-pcre=../module/pcre-8.36 \
--with-ipv6 \
--with-syslog \
--with-jemalloc \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_sub_module  \
--with-http_dav_module \
--with-http_slice_module \
--with-http_gzip_static_module \
--with-http_concat_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module  \
--with-http_sysguard_module \
--with-http_stub_status_module \
--with-http_upstream_check_module  \
--with-http_lua_module \
--with-backtrace_module \
--with-http_image_filter_module \
--with-google_perftools_module \
--http-client-body-temp-path=/opt/tengine/cache/client_temp \
--http-proxy-temp-path=/opt/tengine/cache/proxy_temp  \
--http-fastcgi-temp-path=/opt/tengine/cache/fastcgi_temp  \
--http-uwsgi-temp-path=/opt/tengine/cache/uwsgi_temp  \
--http-scgi-temp-path=/opt/tengine/cache/scgi_temp \
--add-module=../module/ngx_pagespeed \
--add-module=../module/ngx_devel_kit \
--add-module=../module/nginx_tcp_proxy_module \
--add-module=../module/echo-nginx-module \
--add-module=../module/ngx_cache_purge

make 
make install


#--add-module=/root/tengine/module/lua-nginx-module \

mkdir /opt/tengine/cache/client_temp -p
mkdir /opt/tengine/cache/proxy_temp -p
mkdir /opt/tengine/cache/fastcgi_temp  -p
mkdir /opt/tengine/cache/uwsgi_temp  -p
mkdir /opt/tengine/cache/scgi_temp -p
mkdir /opt/tengine/vhost -p
mkdir /opt/tengine/run -p


chown www:www /opt/tengine -R
chmod 777 /opt/tengine/cache/ -R

echo 'export PATH=$PATH:/opt/tengine/bin' >> /etc/profile 
echo 'export PATH=$PATH:/opt/tengine/sbin' >> /etc/profile 
source  /etc/profile 

exit;

cp -rf vhost/* /opt/tengine/vhost/
cp -rf conf/* /opt/tengine/conf

cat init.d/nginx > /etc/init.d/nginx 

chmod 755 /etc/init.d/nginx

service nginx restart

netstat -tupln | grep nginx


 

